<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Home::index');
$routes->get('/login', 'Home::login');
$routes->get('/dash', 'Home::dash');
$routes->get('/user', 'Home::user');
$routes->get('/info', 'Home::info');

$routes->get('/news', 'Home::news');
$routes->get('/news/(:num)', 'Home::detail/$1');

$routes->post('/auth/reg', 'Auth::register');
$routes->post('/auth/login', 'Auth::login');
$routes->post('/auth/forget', 'Auth::forget');
$routes->post('/auth/check', 'Auth::check', ['filter' => 'auth']);
$routes->post('/auth/profile', 'Auth::profile', ['filter' => 'auth']);
$routes->post('/auth/unzip', 'Auth::unzip', ['filter' => 'auth']);
$routes->get('/auth/logout', 'Auth::logout', ['filter' => 'auth']);

$routes->group('/admin', ['filter' => 'auth'], static function ($routes) {
    $routes->get('user/index', 'User::index');

    $routes->get('news/index', 'News::index');
    $routes->get('news/(:num)', 'News::detail/$1');
    $routes->post('news/create', 'News::create');
    $routes->post('news/modify/(:num)', 'News::modify/$1');

    $routes->post('news/publish/(:num)', 'News::publish/$1');
    $routes->post('news/recall/(:num)', 'News::recall/$1');

    $routes->post('news/delete/(:num)', 'News::delete/$1');
    $routes->post('news/recovery/(:num)', 'News::recovery/$1');

    $routes->post('news/batch', 'News::batch');
    $routes->get('news/users', 'News::users');
    $routes->post('news/upload', 'News::upload');
});

$routes->post('/test/email', 'Test::email');
$routes->get('/test/info', 'Test::info');